/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package interp;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Mikael Köhlmyr | mikael@kohlmyr.com | http://www.kmyr.net
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        File file = new File("main.bb");

        if(!file.exists() || !file.isFile() || !file.canRead()){
            System.out.println("File could not be accessed");
        }
        else{
            try{
                String content = "";
                String str;
                //FileInputStream in = new FileInputStream(file);
                BufferedReader br = new BufferedReader(new FileReader(file));
                while ((str = br.readLine()) != null) {
                    content += str;
                }
                br.close();
                Interpreter interp = new Interpreter(strToList(content));
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
    }

    public static ArrayList<String> strToList(String input){
        ArrayList<String> code = new ArrayList<String>();
        Pattern pat = Pattern.compile("[a-zA-Z0-9]+");
        Matcher mat = pat.matcher(input);
        while(mat.find()){
            code.add(mat.group());
        }
        return code;
    }
}